home *** CD-ROM | disk | FTP | other *** search
/ PC World 2007 March / PCWorld_2007-03_cd.bin / domacnost a kancelar / scribus / scribus-1.3.3.7-win32-install.exe / lib / lib-old / find.py < prev    next >
Text File  |  2004-07-27  |  757b  |  27 lines

  1. import fnmatch
  2. import os
  3.  
  4. _debug = 0
  5.  
  6. _prune = ['(*)']
  7.  
  8. def find(pattern, dir = os.curdir):
  9.     list = []
  10.     names = os.listdir(dir)
  11.     names.sort()
  12.     for name in names:
  13.         if name in (os.curdir, os.pardir):
  14.             continue
  15.         fullname = os.path.join(dir, name)
  16.         if fnmatch.fnmatch(name, pattern):
  17.             list.append(fullname)
  18.         if os.path.isdir(fullname) and not os.path.islink(fullname):
  19.             for p in _prune:
  20.                 if fnmatch.fnmatch(name, p):
  21.                     if _debug: print "skip", `fullname`
  22.                     break
  23.             else:
  24.                 if _debug: print "descend into", `fullname`
  25.                 list = list + find(pattern, fullname)
  26.     return list
  27.